<template>
  <div>
    <h2>{{name}}</h2>
    <h2>{{counter}}</h2>
    <button @click="homeIncrement">home +1</button>
  </div>
</template>

<script>
import { inject } from "vue";
//子组件最好不要对父组件传过来的值进行修改
export default {
  setup(){
    //导入
    const name = inject("name");
    const counter = inject("counter");

    const homeIncrement = () => {
      counter.value++;
    }

    return{
      name,
       counter,
      homeIncrement
    }
  }
}
</script>

<style scoped>

</style>